import java.util.Map;

import org.apache.storm.task.OutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichBolt;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;

public class bolt2_1 extends BaseRichBolt {

    private static final long serialVersionUID = 886149197481637894L;
    private OutputCollector collector;

    public void prepare(Map stormConf, TopologyContext context,
                        OutputCollector collector) {
        this.collector = collector;
    }

    public void execute(Tuple input) {
        //获取数据同时进行简单的数据预处理
        String total_price = input.getStringByField("total").replaceAll("^\"|\"$", "");
        String guest_name=input.getStringByField("guest_name").replaceAll("^\"|\"$", "");
        String receiveplace=input.getStringByField("receiveplace").replaceAll("^\"|\"$", "");
        String pay=input.getStringByField("pay").replaceAll("^\"|\"$", "");
        String address=input.getStringByField("address").replaceAll("^\"|\"$", "");
        int all=input.getIntegerByField("begin_2")+1;
        collector.emit(new Values(total_price,guest_name,receiveplace,pay,all));
        collector.ack(input);
    }

    public void declareOutputFields(OutputFieldsDeclarer declarer) {
        declarer.declare(new Fields("total_price","guest_name","receiveplace","pay","all"));
    }
}